<?php

namespace Common\Model;

/**
 * VipUserModel.class.php实例模型
 *
 * @author zhangzhen
 * @date 2017-2-16
 */
class VipUserModel extends BaseModel {

    protected $trueTableName = 'tb_vip_user';

    /**
     * 返回会员设置数据
     * @modify zhangzhen 2017-02-15    获取掌柜的会员设置信息
     * @param integer $hotelId 客栈ID
     * @return type
     */
    public function getInfoById($id) {
        $option = [
            'id'=> $id,
        ];
        $field = 'id,hotelentity_id,vipinfo_id,name,areacode,mobile,identity';
        $data = $this->field($field)->where($option)->find();

        return empty($data) ? array() : $data;
    }
    /**
     * 返回会员设置数据
     * @modify zhangzhen 2017-02-15    获取掌柜的会员设置信息
     * @param integer $hotelId 客栈ID
     * @param integer $name    等级名称
     * @return type
     */
    public function getInfoByMobile($hotelId,$mobile,$areaCode = '86') {
        $option = [
            'hotelentity_id'=> $hotelId,
            'mobile'=> $mobile,
            'areacode'=> $areaCode,
        ];
        $field = 'id,hotelentity_id,vipinfo_id,name,areacode,mobile,identity';
        $data = $this->field($field)->where($option)->find();

        return empty($data) ? array() : $data;
    }

     /**
     * 获取会员所有客栈信息
     * @modify wenhui 2018-01-17
     * @param integer $mobile 客栈ID
     * @param integer $areaCode    等级名称
     * @return type
     */
    public function getUserInfoByMobile($mobile, $areaCode = '86') {
        $option = [
            'mobile'=> $mobile,
            'areacode'=> $areaCode,
        ];

        $field = 'id,hotelentity_id,vipinfo_id,name,areacode,mobile,identity';
        $data = $this->field($field)->where($option)->select();

        return empty($data) ? array() : $data;
    }
}
